//
//  YuHintLabel.m
//  HuLaQuan
//
//  Created by hok on 3/16/16.
//  Copyright © 2016 yuwubao. All rights reserved.
//

#import "YuHintLabel.h"

#define LINESPACE 5.0

@implementation YuHintLabel

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.numberOfLines = 0; // 需要把显示行数设置成无限制
        
        [self addLineSpaceForText:self.text];
        
        
    }
    return self;
}
- (void)setup
{
    self.textAlignment = NSTextAlignmentLeft;
    self.textColor = UIColorFromRGBA(0x202020, 1.0);
    self.font = [UIFont fontWithName:FONT_NAME size:13];
}
- (void)setText:(NSString *)text{
    [super setText:text];
    [self addLineSpaceForText:text];
    //  self.text = text;
}

- (void)addLineSpaceForText:(NSString *)text{
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:LINESPACE];//调整行间距
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];

    self.attributedText = attributedString;
}
@end
